package com.giaothong.customview;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.giaothong.R;
import com.giaothong.model.entity.LocationSearchEntity;
import com.giaothong.utils.ImageLoaderUtils;

public class LocationInfoItemView extends LinearLayout {

	private View layout;
	private Context mContext;
	private ImageView imgIcon;
	private TextView txtNameLocation, txtAddress;

	public LocationInfoItemView(Context context) {
		super(context);
		this.mContext = context;
		init();
	}

	public LocationInfoItemView(Context context, AttributeSet attrs) {
		super(context, attrs);
		this.mContext = context;
		init();
	}

	private void init() {
		LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		layout = inflater.inflate(R.layout.layout_location_item, this);
		imgIcon = (ImageView) layout.findViewById(R.id.imgIcon);
		txtAddress = (TextView) layout.findViewById(R.id.txtAddress);
		txtNameLocation = (TextView) layout.findViewById(R.id.txtNameLocation);
	}

	/**
	 * set data in comment
	 * 
	 * @param commentEntity
	 */
	public void setData(LocationSearchEntity locationSearchEntity) {
		ImageLoaderUtils.getImageLoader(mContext).displayImage(locationSearchEntity.getIcon(), imgIcon, ImageLoaderUtils.getOptionLoader());
		txtAddress.setText(locationSearchEntity.getAddress());
		txtNameLocation.setText(locationSearchEntity.getName());
	}

}
